package com.pet.customer.controller;


import com.pet.customer.mapper.CustomerMapper;
import com.pet.customer.model.Customer;
import com.pet.customer.util.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


@RestController
public class RegisterController {
    @Autowired
    private CustomerMapper customerMapper;

    @RequestMapping(value="/doRegister",method = RequestMethod.POST)
    public String register(HttpServletRequest request, Model model) {
        String email = request.getParameter("email");
        String password = request.getParameter("password");
        String passMd5 = Md5Util.MD5(password);
        Customer customer = new Customer();
        customer.setEmail(email);
        customer.setPassword(passMd5);
        customerMapper.insertSelective(customer);
        return "OK";
    }

}